use std::collections::LinkedList;
use std::collections::VecDeque;
use std::fmt::Debug;
enum Number {
    Zero,
    One,
    Two,
}
fn main() {
    //枚举

    let a = Number::One;

    match a {
        Number::Zero => println!("0"),
        Number::One => println!("1"),
        Number::Two => println!("12"),
    };
    // println!("{}",a);

    //线性序列---向量
    let mut v1 = vec![];
    v1.push(String::from("hello"));
    // v1.push(1); //类型必须匹配上
    v1.push("word".to_string());

    println!("{:?}", v1);

    //线性序列---双端队列
    let mut buf = VecDeque::new();
    //追加在队列的前面，相当于js 的unshift
    buf.push_front(1);
    buf.push_front(2);
    buf.push_front(6);
    //追加在队列的后面，相当于js 的push
    buf.push_back(3);
    buf.push_back(4);

    println!("{:#?}", buf);

    //线性序列---链表
    let mut list1 = LinkedList::new();

    list1.push_back("a");
    list1.push_back("b");
    list1.push_back("c");
    let mut list2 = LinkedList::new();
    list2.push_back("e");
    list2.push_back("f");

    list1.append(&mut list2); //拼接

    println!("list1={:?}", list1);
    println!("list2={:?}", list2);

    list1.pop_front(); //删除最前一个
    println!("list1={:?}", list1);
    list1.pop_back(); //删除最后一个
    println!("list1={:?}", list1);

let a:Option<i32>=Some(3);
let b:Option<&str>=Some("hello");
let c:Option<char>=Some('A');
let d:Option<u32>=None;

match_option(a);
match_option(b);
match_option(c);
match_option(d);



}
fn match_option<T: Debug>(o: Option<T>) {
    match o {
        Some(i) => println!("{:?}", i),
        None => println!("nothing"),
    }
}
